package zhongbo.java.air.airflightpath.config;

/*
 配置redis Sub订阅监听者Listener
 */

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.Topic;
import zhongbo.java.air.airflightpath.listener.RedisSubscribeLogChanelListener;

@Slf4j
@Configuration
public class RedisListenerConfig {

    public  static String LOG_CHANEL="log_chanel";


    @Autowired
    //RedisSubscribeLogChanelListener处理接受的消息
    public void configListener(RedisMessageListenerContainer listenerContainer,
                               RedisSubscribeLogChanelListener logChanelListener){
        log.info("配置redis监听器");
        //配置RedidLogSubscribeListener监听频道 log_chanel接收消息
        //PatternTopic监听的频道模式
        Topic logTopic =new PatternTopic(LOG_CHANEL);
        listenerContainer.addMessageListener(logChanelListener,logTopic);
    }

}
